package com.ustudy.entity.sns;

import java.util.Collections;
import java.util.List;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.ustudy.core.dao.support.entity.LongIdEntity;

import com.ustudy.entity.iden.RegUser;

/**
 * 主题
 * @author caizh
 *
 */
@SuppressWarnings("serial")
@Entity(name="Topic")
@Table(name="SNS_FORUM_TOPIC")
public class Topic extends LongIdEntity {
	
	private String title;
	
	@Column
	@Lob
	@Basic(fetch=FetchType.LAZY)
	private String body;
	
	@ManyToOne(cascade={CascadeType.REFRESH},fetch=FetchType.LAZY)
	@JoinColumn(name="USER_ID")
	private RegUser regUser;
	
	private Long pubTime=System.currentTimeMillis();
	
	@ManyToOne(cascade={CascadeType.REFRESH},fetch=FetchType.LAZY)
	@JoinColumn(name="SECTION_ID")
	private ForumSection forumSection;
	
	@OneToMany(cascade={CascadeType.REMOVE},fetch=FetchType.LAZY,mappedBy="topic")
	private List<FollowPoster> followPosters=Collections.emptyList();
	
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getBody() {
		return body;
	}

	public void setBody(String body) {
		this.body = body;
	}

	public RegUser getRegUser() {
		return regUser;
	}

	public void setRegUser(RegUser regUser) {
		this.regUser = regUser;
	}

	public Long getPubTime() {
		return pubTime;
	}

	public void setPubTime(Long pubTime) {
		this.pubTime = pubTime;
	}

	public ForumSection getForumSection() {
		return forumSection;
	}

	public void setForumSection(ForumSection forumSection) {
		this.forumSection = forumSection;
	}

	public List<FollowPoster> getFollowPosters() {
		return followPosters;
	}

	public void setFollowPosters(List<FollowPoster> followPosters) {
		this.followPosters = followPosters;
	}
}
